package com.example.newapplication;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class test extends Activity 
                        implements View.OnClickListener {
	
    private static final int DIALOG_DUMMY = 1;
    
	private Button dialogButton;
    private Button toastButton;
    private Toast  toast;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        
        this.dialogButton = (Button)findViewById(R.id.dialogButton);
        this.dialogButton.setOnClickListener(this);
        this.toastButton = (Button)findViewById(R.id.toastButton);
        this.toastButton.setOnClickListener(this);
        
        this.toast = Toast.makeText(this, "Dieser Text verschwindet automatisch nach wenigen Sekunden.", Toast.LENGTH_LONG);
    }
    
    @Override
    public Dialog onCreateDialog(int id) {
    	AlertDialog.Builder db = new AlertDialog.Builder(this);
    	
    	db.setTitle("Dialog");
    	db.setMessage("Hier steht normalerweise etwas Text.");
    	// db.setIcon(R.drawable.icon);
    	db.setPositiveButton("OK", new OnClickListener() {
    		public void onClick(DialogInterface dialog, int id) { }
    	});
    	
    	return db.create();
    }
    
    @Override
    public void onPrepareDialog(int id, Dialog dialog) { }
    
    public void onClick(View view) {
    	if ( view == this.dialogButton ) {
    		showDialog(DIALOG_DUMMY);
    	}
    	else if ( view == this.toastButton ) {
    		this.toast.show();
    	}
    }
}